#pragma once
#include "Device.h"
#include "Shader.h"
#include "DevicePlatform.h"
#include "UnitDerive.h"
#include "Actor.h"
namespace mini
{
	enum  EffectOrder
	{
		Effect_Default      = 0,
		Effect_Light		= 0,
		Effect_Water		= 1,
		Effect_Instance		= 2,
	};

	class CEffect : public CActor
	{
	public:
		CEffect();
		virtual ~CEffect();
		virtual bool init(CDevice* pDevice);
		virtual void addActor(CActor* pActor);
		virtual void removeActor(CActor* pActor);
		virtual void clearAllActors();
		virtual void commitToGpu(DeviceContext* pDeviceContext);
		virtual void addUnit(CUnit* pUnit, EntityType Type, INT32 zLayer);

		void cleanUnit();

		EffectOrder getOrder();
		void bindMaterial(const std::string& szName);
		
	protected:
		CDevice* mpDevice = nullptr;
		CShader* mpShader = nullptr;
		std::list<CActor*>	mActors;
		EffectOrder			mOrder = Effect_Default;
		CMaterialUnit* mpMaterialUnit = nullptr;
	
		std::map<CShaderUnit*, std::list<CMeshUnit*> >			mRenderUnits;
		std::map<CShaderUnit*, std::list<CMeshUnit*> >			mAlphaRenderUnits;
		std::map<INT32, std::pair< CShaderUnit*, CMeshUnit*> >	mZbufferOffRenderUnits;
	};
}